@IRévisé en juillet 1993. N'est pas du Domaine Publique.
@ITous Droits Réservés.
Traduit par Fabien Larini le 23/07/93.
Ce Génie fait rentrer tout le texte dans une boîte ou une chaîne de boîtes
en respectant les proportions des tailles de caractères. Tout le texte
dans la boîte sera modifié. Il n'y a pas création de boîtes comme dans
ImportationAuto. Il doit y avoir du texte dans la boîte avant de lancer
le Génie.
Remarque : les formats de styles appliqués au texte seront annulés. Le
facteur minimal de réduction est 1/8 point dans les tailles de caractères
disponibles. Ce Génie préfère sous-remplir une boîte que de la faire
déborder
*/
/*FitTextToBoxes*/
/* This Genie will fit text into a box or chain of boxes, keeping the proportions of differing sizes of text in a box. All the text in a box or linked chain will be changed. No new boxes are created, unlike AutoImport. The text must be already in the box before running the genie.
Note that any style tags applying to the text will be cancelled.
The limiting factor for accurate fitting is the 1/8 point step in the available font sizes. I have set the genie to underflow rather than overflow.
Written by Don Cox July 92 Revised July 93 Not Public Domain. All rights reserved. */
trace n
signal on error
signal on syntax
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
cr="0a"x
cpage = ppm_CurrentPage()
counter=0
do forever
box=ppm_ClickOnBox("Clickez dans les Boîtes où le Texte doit être Ajusté")
if box=0 then break
counter=counter+1
boxes.counter=box
call ppm_SelectBox(box)
end
if counter=0 then exit_msg("Pas de Boîte Sélectionnée")
currentunits=ppm_GetUnits()
call ppm_SetUnits(2)
call ppm_ShowStatus("Ajustement du Texte ...")
do i=1 to counter
box=boxes.i
boxtype = upper(word(ppm_GetBoxInfo(box), 1))
if boxtype~="TEXTE" then iterate
box = ppm_ArtFirstBox(box)
text = ppm_GetArticleText(box,1)
iter = 1
factor = 0.5 /* first find max size quickly */
do 9 /* 9 is enough doublings */
factor2 = factor /* format number for display */
if pos(".",factor2) = 0 then factor2 = factor||"."
factor2 = left(factor2,8,"0")
call ppm_ShowStatus("Ajustement du Texte ... Itération "right(iter,2," ")" Rapport "factor2)
oldfactor = factor
factor = factor*2
newtext = text /* go back to original each time */
newtext = ResizeFonts(newtext,factor)
if newtext~="" then do /* ResizeFonts returns empty string if over size limit (720 points) */
gone = ppm_DeleteContents(box)
overflow = ppm_TextIntoBox(box,newtext)
end
if newtext="" | overflow = 1 then break
end
max = factor
factor = (oldfactor+factor)/2
min = 0
do 18 /* Don't go on iterating for ever... */
factor2 = factor /* format number for display */
if pos(".",factor2) = 0 then factor2 = factor||"."
factor2 = left(factor2,8,"0")
call ppm_ShowStatus("Ajustement du Texte ... Itération "right(iter,2," ")" Rapport "factor2)
iter = iter+1
newtext = text /* go back to original each time */
newtext = ResizeFonts(newtext,factor)
if newtext~="" then do /* ResizeFonts returns empty string if over size limit (720 points) */
gone = ppm_DeleteContents(box)
overflow = ppm_TextIntoBox(box,newtext)
end
if overflow = 1 | newtext = "" then do
max = factor
factor = (factor+min)/2
end
else do
min = factor
factor = (factor+max)/2
end
end
factor = min /* just reduce a little at the end to cover the oscillations */
newtext = ResizeFonts(text,factor) /* go back to original each time */